package com.ydzh.kfqgwvisitor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ydzh.kfqgwvisitor.entity.BeVisitor;
import com.ydzh.kfqgwvisitor.mapper.BeVisitorMapper;
import com.ydzh.kfqgwvisitor.service.BeVisitorService;
import com.ydzh.kfqgwvisitor.vo.BeVisitorVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 * 被访人信息表  服务实现类
 * </p>
 *
 * @author zcj
 * @since 2021-09-01
 */
@Service
public class BeVisitorServiceImpl extends ServiceImpl<BeVisitorMapper, BeVisitor> implements BeVisitorService {

    @Autowired
    private BeVisitorMapper mapper;


    @Override
    public List<BeVisitorVO> listToAll(Long unitId, Long departmentId) {
        if (Objects.isNull(unitId)) {
            // 不管有没有传部门都可以使用此sql
            return mapper.listByDeptId(departmentId);
        }
        // 若参数有单位的ID那就使用此sql
        return mapper.findByUnitId(unitId, departmentId);
    }
}
